require.config({
    baseUrl:"./modules",
    path:{
        jq:"../libs/jquery"
    }
})

require(["jq","getGoods"],function(_,getGoods){
    // console.log($);
    // console.log(getGoods);
    // 首先请求商品数据
    getGoods((res)=>{
        // console.log(res);
        // 再请求本地存储数据
        const goodsMsg=localStorage.getItem("goodsMsg")?JSON.parse(localStorage.getItem("goodsMsg")):[];
        console.log(res,goodsMsg);
        // 渲染页面
        let str="";
        res.forEach(val1 => {
            goodsMsg.forEach(val2=>{
                console.log(val1.goodsId,val2.id);
                if(val1.goodsId===val2.id){
                    str += `<tr index="${val2.id}">
                    <td align="center"><input class="checks" type="checkbox" ${val2.flag ? 'checked' : ''}></td>
                    <td><img src="${val1.proImg}" class="td-img" alt=""></td>
                    <td>${val1.proName}</td>
                    <td><input type="number" value="${val2.num}" class="setNum"></td>
                    <td>${val1.price}</td>
                    <td>${val1.price * val2.num}</td>
                    <td class="del">删除</td>
                    </tr>`
                }
            })
        });
        $("tbody").html(str);
    })
})